//
//  CQDiscoverTextField.m
//  01-OC微博
//
//  Created by 陈乾 on 15/10/27.
//  Copyright © 2015年 陈乾. All rights reserved.
//

#import "CQDiscoverTextField.h"
#import "UIImage+CQImage.h"

@implementation CQDiscoverTextField
/**
 *
 * 封装了一个专门用来收索的textField
 */
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        //拉伸背景图片
        self.background = [UIImage  imageStretchableWithImageName:@"searchbar_textfield_background"];
        
        //设置左边的放大镜图片
        UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"searchbar_textfield_search_icon"]];
        
        //让图片变宽 让后让图片居中 就能产生图片和文字之间的距离
        imageView.width += 10;
        imageView.contentMode = UIViewContentModeCenter;
        //设置左边的view
        self.leftView = imageView;
        //设置模式 一致显示
        self.leftViewMode = UITextFieldViewModeAlways;
        
        
    }
    return self;
}

@end
